<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>潜在客户管理</title>
<jsp:include page="../inc.jsp" flush="false"></jsp:include>
<script type="text/javascript"
        src="${pageContext.request.contextPath}/plug-in/custom/form.js"
        charset="utf-8"></script>

<script type="text/javascript">
Ext.onReady(function () {
    Ext.QuickTips.init();
    createForm();
    form = Ext.create('potentialCustomersForm');
    createLayout();

    form.getForm().load({

        url: getRootPath()+"/potentialCustomersController/info.action",
        method: "POST",
        params: {
            id: '<%=request.getParameter("potentialCustomersId")%>'
        },
        waitTitle:'提示',
        waitMsg:'正在处理您的请求,请稍候...',
        success:function(form,action){
            tabPanel.add({
                id: "tab5",
                title: '通信历史',
                height:600,
                html : '<iframe scrolling="auto" frameborder="0"   width="100%" height="100%" src="communicationHistory.jsp?businessKey=<%=request.getParameter("Id")%>&receptionName='+form.findField("name").getValue()+'&phone='+form.findField("phone").getValue()+'&email=' +form.findField("email").getValue()+'"></iframe>'
            });
            form.findField("state").setValue( getCodeItemText('潜在客户状态',action.result.data.state));
            form.findField("source").setValue( getCodeItemText('来源',action.result.data.source));
            form.findField("industry").setValue( getCodeItemText('行业',action.result.data.industry));

        }

    });

});

var  form, tabPanel;


// 创建form表单
function createForm() {
    Ext.define('potentialCustomersForm', {
        extend: 'Ext.form.Panel',
        fields: new Ext.util.MixedCollection(),
        initComponent: function () {
            this.fields.add('id', new Ext.form.Hidden({
                name: 'id',
                dataIndex: 'id'
            }));
            this.fields.add('state', new Ext.form.DisplayField({
                name: 'state',
                dataIndex: 'state',
                fieldLabel: '状态',
                allowBlank: false
            }));
            this.fields.add('name', new Ext.form.DisplayField({
                name: 'name',
                dataIndex: 'name',
                fieldLabel: '姓名',
                allowBlank: false
            }));
            this.fields.add('phone', new Ext.form.DisplayField({
                name: 'phone',
                dataIndex: 'phone',
                fieldLabel: '手机',
                allowBlank: true
            }));
            this.fields.add('officePhone', new Ext.form.DisplayField({
                name: 'officePhone',
                dataIndex: 'officePhone',
                fieldLabel: '办公电话',
                allowBlank: true
            }));
            this.fields.add('company', new Ext.form.DisplayField({
                name: 'company',
                dataIndex: 'company',
                fieldLabel: '公司',
                allowBlank:false
            }));
            this.fields.add('email', new Ext.form.DisplayField({
                name: 'email',
                dataIndex: 'email',
                fieldLabel: '电子邮箱',
                allowBlank: true
            }));
            this.fields.add('position', new Ext.form.DisplayField({
                name: 'position',
                dataIndex: 'position',
                fieldLabel: '职务',
                allowBlank: true
            }));
            this.fields.add('hotSpot',new Ext.form.Checkbox({
                name: 'hotSpot',
                dataIndex: 'hotSpot',
                fieldLabel: '热点',
                labelAlign: 'right',
                inputValue: 1
            }));
            this.fields.add('numberOfEmployees', new Ext.form.DisplayField({
                name: 'numberOfEmployees',
                dataIndex: 'numberOfEmployees',
                allowDecimals: false,
                decimalPrecision: null,
                fieldLabel: '职员数',
                allowBlank: true
            }));
            this.fields.add('source', new Ext.form.DisplayField({
                name: 'source',
                dataIndex: 'source',
                allowDecimals: false,
                decimalPrecision: null,
                fieldLabel: '来源',
                allowBlank: true
            }));

            this.fields.add('annualTurnover', new Ext.form.DisplayField({
                name: 'annualTurnover',
                dataIndex: 'annualTurnover',
                allowDecimals: true,
                decimalPrecision: 2,
                fieldLabel: '年营业额',
                allowBlank: true
            }));
            this.fields.add('industry', new Ext.form.DisplayField({
                name: 'industry',
                dataIndex: 'industry',
                allowDecimals: true,
                decimalPrecision: 2,
                fieldLabel: '行业',
                allowBlank: true
            }));

            this.fields.add('registeredCapital', new Ext.form.DisplayField({
                name: 'registeredCapital',
                dataIndex: 'registeredCapital',
                allowDecimals: true,
                decimalPrecision: 2,
                fieldLabel: '注册资金',
                allowBlank: true
            }));
            this.fields.add('zip', new Ext.form.DisplayField({
                name: 'zip',
                dataIndex: 'zip',
                fieldLabel: '邮编',
                allowBlank: true
            }));
            this.fields.add('website', new Ext.form.DisplayField({
                name: 'website',
                dataIndex: 'website',
                fieldLabel: '网址',
                allowBlank: true
            }));
            this.fields.add('address', new Ext.form.DisplayField({
                name: 'address',
                dataIndex: 'address',
                fieldLabel: '地址',
                allowBlank: true
            }));

            this.fields.add('remark', new Ext.form.DisplayField({
                name: 'remark',
                dataIndex: 'remark',
                fieldLabel: '备注',
                allowBlank: true
            }));

            this.items = [ this.fields.get('id'), {
                xtype: 'fieldset',
                title: '潜在客户信息',
                collapsible: true,
                defaults: {
                    labelWidth: 89,
                    anchor: '100%',
                    layout: {
                        type: 'hbox',
                        defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
                    }
                },
                items: [{
                    xtype: 'container',
                    layout: 'hbox', defaults: {
                        flex: 1,
                        hideLabel: true
                    },
                    margin: '0 0 5 0',
                    items:  [ this.fields.get('company'),this.fields.get('state')]},
                    {
                        xtype: 'container',
                        layout: 'hbox',
                        margin: '0 0 5 0',
                        defaults: {
                            flex: 1,
                            hideLabel: true
                        },
                        items: [ this.fields.get('name'), this.fields.get('phone')]}, {
                        xtype: 'container',
                        layout: 'hbox', defaults: {
                            flex: 1,
                            hideLabel: true
                        },
                        margin: '0 0 5 0',
                        items: [ this.fields.get('officePhone'), this.fields.get('email')]}, {
                        xtype: 'container',
                        layout: 'hbox',
                        defaults: {
                            flex: 1,
                            hideLabel: true
                        },
                        margin: '0 0 5 0',
                        items: [ this.fields.get('position'), this.fields.get('hotSpot')]}
                   ]},
                {
                    xtype: 'fieldset',
                    title: '其他信息',
                    collapsible: true,
                    defaults: {
                        labelWidth: 89,
                        anchor: '100%',
                        layout: {
                            type: 'hbox',
                            defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
                        }
                    },
                    items: [
                        {
                            xtype: 'container',
                            layout: 'hbox',
                            defaults: {
                                flex: 1,
                                hideLabel: true
                            },
                            margin: '0 0 5 0',
                            items: [ this.fields.get('numberOfEmployees'), this.fields.get('annualTurnover')]},

                        {
                            xtype: 'container',
                            layout: 'hbox',
                            margin: '0 0 5 0',
                            defaults: {
                                flex: 1,
                                hideLabel: true
                            },
                            items: [  this.fields.get('source') ,this.fields.get('industry')]},
                        {
                            xtype: 'container',
                            layout: 'hbox',
                            margin: '0 0 5 0',
                            defaults: {
                                flex: 1,
                                hideLabel: true
                            },
                            items: [ this.fields.get('registeredCapital')]}
                    ]},
                {
                    xtype: 'fieldset',
                    title: '地址信息',
                    collapsible: true,
                    defaults: {
                        labelWidth: 89,
                        anchor: '100%',
                        layout: {
                            type: 'hbox',
                            defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
                        }
                    },
                    items: [
                        {
                            xtype: 'container',
                            layout: 'hbox',
                            defaults: {
                                flex: 1,
                                hideLabel: true
                            },
                            margin: '0 0 5 0',
                            items: [this.fields.get('zip'),
                        this.fields.get('website')]},
                       this.fields.get('address')
                        ]},
                {
                    xtype: 'fieldset',
                    title: '备注',
                    collapsible: true,
                    defaults: {
                        labelWidth: 89,
                        anchor: '100%',
                        layout: {
                            type: 'hbox',
                            defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
                        }
                    },
                    items: [this.fields.get('remark')]}];
            this.xtype = 'form';
            this.frame = false;
            this.border = false;
            this.split = true;
            this.bodyPadding = 10,
                    this.autoScroll = true,//自动出滚动条
                    this.bodyBorder = true;
            this.fieldDefaults = {
                labelWidth: 80,
                labelAlign: 'right',
                msgTarget: 'side'
            };
            this.defaults = {
                anchor: '100%'
            };
            this.callParent(arguments);
        },
        onRender: function () {
            this.callParent(arguments);
        },
        newDataRecord: function () {
            this.getForm().reset();
        }
    });
}





// 创建layout
function createLayout() {
    tabPanel= Ext.create('Ext.tab.Panel', {
        layout: 'fit',
        activeTab: 0,                       //指定默认的活动tab
        plain: true,                        //True表示tab候选栏上没有背景图片（默认为false）
        enableTabScroll: true,              //选项卡过多时，允许滚动
        defaults: { autoScroll: true },
        listeners:{
            tabchange:function(tp,p){

            }
        } ,
        items: [{
            id: "tab1",
            title: '详细信息',
            items:[form],
            closable: false                  //这个tab可以被关闭
        },{
            id: "tab2",

            title: '计划的活动',

            html : '<iframe scrolling="auto" frameborder="0"   width="100%" height="100%" src="programActivities.jsp?entityID=<%=request.getParameter("Id")%>"></iframe>'
        } , {
            id: "tab3",
            title: '附件',

            html : '<iframe scrolling="auto" frameborder="0"   width="100%" height="100%" src="${pageContext.request.contextPath}/upload/attachment.jsp?businessKey=<%=request.getParameter("Id")%>"></iframe>'
        }]
    });
    var viewport = new Ext.Viewport({
        layout: 'fit',
        region: 'center',
        border: false,
        items: [
            tabPanel
        ]
    });
    viewport.doLayout();
}
</script>
</head>
<body>
</body>
</html>